package com.mars.foodserver.controller.app;

import com.mars.foodserver.controller.common.BaseController;
import com.mars.foodserver.response.result.R;
import com.mars.foodserver.response.vo.FoodCommentVo;
import com.mars.foodserver.service.IFoodCommentService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wq
 * @since 2021-07-21
 */
@RestController
@RequestMapping("note/comment")
@AllArgsConstructor
public class NotesCommentController extends BaseController {

    final IFoodCommentService foodCommentService;

    /**
     * 创建评论
     *
     * @param noteId  笔记ID
     * @param comment 评论内容
     */
    @GetMapping("/createComment")
    public R<Void> createComment(Integer noteId, String comment) {
        foodCommentService.createComment(getUserId(), noteId, comment);
        return R.success();
    }

    /**
     * 评论列表
     *
     * @param noteId noteId
     * @return R
     */
    @GetMapping("/list")
    public R<List<FoodCommentVo>> list(Integer noteId) {
        return R.success(foodCommentService.list(noteId));
    }


}
